home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln1285.arc
/
CROSSTH3.LTG
next >
Wrap
Text File
|
1986-02-27
|
2KB
|
75 lines
Listing 3.
PPL code for concurrent matrix LU decomposition
FUNCTION LU_Decomposition(VAR A : array[1..MAX,1..MAX] of real;
N : integer) return boolean
è-- Matrix A is converted into a L\U matrix
BEGIN
Priority = 1
INITIALIZE: Set first colum of L\U matrix = first column of matrix A
LOOP <Complete first row>
BEGIN For i = 2 to N
L\U[1,i] = A[1,i] / A[1,1]
END LOOP <Complete first row>
TERMINATE: None
INITIALIZE: i = 2; Found_Error = FASLE
LOOP <Set Column>
BEGIN IF (i > N) OR Found_Error THEN EXIT <Set Column> END IF
L\U[i,i] = A[i,i] - (vector of all elements to the left of L\U[i,i])
* (vector of all elements above L\U[i,i])
INITIALIZE: First = i
LOOP <Find Zero Diagonals>
BEGIN IF (L\U[First,i] <> 0) AND (NOT Found_Error)
THEN EXIT <Find Zero Diagonals> END IF
First += 1
IF First <= N THEN Calculate L\U[First,i]
ELSE Found_Error = TRUE
END LOOP <Find Zero Diagonals>
IF Found_Error THEN EXIT <Set column> END IF
IF First <> i
THEN Swap rows First and 'i' in matrices A & L\U END IF
IF First < N
THEN StartProcedure(Do_Column(i),Priority, ColSignal) END IF
StartProcedure(Do_Row(i), Priority, RowSignal)
Wait_Signal(ColSignal); Wait_Signal(Row_Signal)
END LOOP
TERMINATE: None
return ( Found_Errors )
END LU_Decomposition
PROCEDURE Do_Column(i : integer)
-- procedure to calculate L\U column elements in the 'i'th column
BEGIN
INITIALIZE:
LOOP
BEGIN For j = i+1 to N
L\U[i,j] = A[i,j] - (vector of members L\U[1,i] to L\U[i-1,i])
* (vector of members L\U[j,1] to L\U[j,i-1)
END LOOP
TERMINATE:
END Do_Column
èPROCEDURE Do_Row(i : integer)
-- procedure to calculate L\U row elements in the 'i'th row
BEGIN
INITIALIZE:
LOOP
BEGIN For j = i+1 to N
L\U[j,i] = A[j,i] - (vector of members L\U[1,i] to L\U[i-1,i])
* (vector of members L\U[j,1] to L\U[j,i-1)
L\U[j,i] /= L\U[i,i] -- divide by diagonal element
END LOOP
TERMINATE:
END Do_Row